import Tooltip from '@/components/tooltip'
import styles from './index.module.less'
import QuestionSvg from '@/svg/question'
import { timestampToYmd, hidePhone } from '@/utils/utils'
import Big from 'big.js'

const columns = () => {
  const cols = [
    {
      left: 40,
      title: '时间',
      width: '17%',
      headerAlign: 'left',
      bodyAlign: 'left',
      render: (row) => {
        return timestampToYmd(row.createTime * 1000, true)
      },
    },
    {
      title: '交易类型',
      dataIndex: 'orderType',
      width: '16%',
      render: (_, type) => {
        switch (type) {
          case 1:
            return '提现'
          default:
            return ''
        }
      },
    },
    {
      title: '交易方式',
      dataIndex: 'orderType',
      width: '16%',
      render: (_, orderType) => {
        switch (orderType) {
          case 1:
            return '支付宝'
          case 2:
            return '微信'
          case 3:
            return 'Paypal'
          default:
            return orderType
        }
      },
    },
    {
      title: '交易账户',
      dataIndex: 'account',
      needHover: true,
      width: '16%',
      render: (_, data) => {
        return hidePhone(data)
      },
    },
    {
      title: '金额',
      dataIndex: 'amount',
      width: '16%',
      render: (_, data) => {
        return '￥' + Big(data).div(100).toFixed(2).toString()
      },
    },
    {
      title: '状态',
      dataIndex: 'orderStatus',
      width: '16%',
      render: (row, status) => {
        const TipDom = (
          <div className={styles.tooltips}>
            <QuestionSvg className="w-4 h-4 mr-1" fill="var(--theme-color)" />
            <div className={styles.right}>用户已发起退款，无法参与分成</div>
          </div>
        )
        switch (status) {
          case 2:
            return (
              <div className={styles.statusBox}>
                <span className={styles.green}>提现成功</span>
              </div>
            )
          case 1:
            return (
              <div className={styles.statusBox}>
                <span className={styles.red}>处理中</span>
              </div>
            )
          case 3:
            return (
              <div className={styles.statusBox}>
                <span className={styles.gray}>处理失败</span>
                <Tooltip text={TipDom} />
              </div>
            )
          default:
            return ''
        }
      },
    },
  ]
  return cols
}

export default columns
